package cn.com.self.apis.portal.service.impl;

import cn.com.self.apis.files.entity.Files;
import cn.com.self.apis.portal.entity.FileRelationEntity;
import cn.com.self.apis.portal.mapper.FileRelationMapper;
import cn.com.self.apis.portal.service.intf.IFileRelationService;
import cn.com.selfsoft.smartcity.core.service.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author CRL
 * @date 2021/2/9 9:04
 */
@Service
public class FileFileRelationServiceImpl extends BaseServiceImpl<FileRelationEntity, String> implements IFileRelationService {

    @Autowired
    FileRelationMapper fileRelationMapper;

    @Override
    public void deleteByObjId(String id) {
        //删除文件数据关联系
        Map<String, Object> queryParams = new HashMap<>();
        queryParams.put("obj_id", id);
        this.fileRelationMapper.deleteByMap(queryParams);
        this.fileRelationMapper.selectById(id);
    }

    @Override
    public List<FileRelationEntity> findByObjId(String id) {
        Map<String, Object> queryParams = new HashMap<>();
        queryParams.put("obj_id", id);
        return fileRelationMapper.selectByMap(queryParams);
    }

    @Override
    public List<Files> findFilesByObjId(Long objId) {
        return fileRelationMapper.findRelationFiles(objId);
    }

}
